<template>
  <div>
    <el-container>
      <el-header>
        <div class="headerConfig">
          <p>Hello: {{username}}</p>
          <el-button @click="outLogin">退出</el-button>
        </div>
      </el-header>

      <el-container class="arr">
        <el-aside width="200px">
            <el-col :span="24">
              <h5>图书管理后台</h5>
              <el-menu
                default-active="Index"
                class="el-menu-vertical-demo"
                @select="selectMenu"
                >
                <el-menu-item index="Index">
                  <i class="el-icon-s-management"></i>
                  <span slot="title">首页</span>
                </el-menu-item>
                <el-menu-item index="Inbook">
                  <i class="el-icon-s-management"></i>
                  <span slot="title">图书管理</span>
                </el-menu-item>
                <el-menu-item index="Borrow">
                  <i class="el-icon-s-unfold"></i>
                  <span slot="title">租借订单</span>
                </el-menu-item>
                <el-menu-item index="Admin">
                  <i class="el-icon-menu"></i>
                  <span slot="title">管理人员</span>
                </el-menu-item>
              </el-menu>
            </el-col>
        </el-aside>

        <el-main>
          <router-view/>
        </el-main>

      </el-container>
    </el-container>
  </div>
</template>

<style lang="scss">
  .el-container {
    height: 100vh;
  }
  .el-header {
    background-image: linear-gradient(to right, #1067D1, #f9f9f9);
    color: #333;
    text-align: center;
    .headerConfig{
      display: flex;
      justify-content: flex-end;
      padding-right: 30px;
      align-items: center;
      .el-button{
        height: 40px;
        margin-left: 40px;
      }
    }
  }    
  
  .arr{
    background-color: #fff;
  }
  .el-aside {
    background-color: #fff;
    color: #333;
    text-align: center;
  }
  
  .el-main {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 160px;
  }
</style>

<script>
export default {
  computed: {
    adminInfo(){
      return JSON.parse(localStorage.getItem('adminInfo'));
    }
  },
  methods: {
    outLogin(){
      localStorage.removeItem("adminInfo",{})
      localStorage.removeItem("isSuperAdmin",{})
      this.$router.push('/Login');
      this.$message.success('退出成功！');
    },

    selectMenu(index){
      this.$router.push(index);
    }
  },
  computed: {
    username() {
      return localStorage.getItem('username') || '未知用户';
    }
  }
}

</script>
